Skip to content

Add outage/exercise session ledger, event platform, and post-outage summary blueprint - #333

Open
binarydev wants to merge 1 commit into
mainfrom
feat/session-ledger-and-events
Open

binarydev wants to merge 1 commit into
mainfrom
feat/session-ledger-and-events

Conversation

@binarydev

Copy link
Copy Markdown
Owner

Summary

PR 1 of 3 for v0.7.0 — adds persistent outage/exercise session tracking, a native Home Assistant event platform for generator lifecycle activity, and a bundled post-outage summary blueprint (addresses #216).

  • Session Ledger & v1 -> v2 Storage Migration (readiness.py):
    • Upgrades HA Store to STORAGE_VERSION = 2 via _ReadinessStore._async_migrate_func, migrating existing v1 records transparently without resetting service_baseline_hours or last_exercise_ts.
    • Separates observed/inferred outage and exercise timestamps from the day-1 missed-exercise grace clock so fresh and upgraded installs show unknown until a real run occurs.
    • Classifies unobserved run_time increases between idle polls: short runs (within configured single-cycle exercise_minutes + 5 min buffer, clamped to 1–60 min to ignore cumulative values, or <= 21 min default) record an inferred exercise; longer deltas record an inferred outage with duration and estimated fuel used.
    • Persists active session state and fault_active across restarts so reloads never emit duplicate start/fault events or miss clearances.
  • New Generator Sensors (sensor.py):
    • Last Outage (last_outage, SensorDeviceClass.TIMESTAMP)
    • Last Exercise (last_exercise, SensorDeviceClass.TIMESTAMP)
    • Last Outage Duration (last_outage_duration, SensorDeviceClass.DURATION, min, MEASUREMENT, with started_at, ended_at, run_hours_delta, estimated_fuel_used, and inferred attributes)
  • Native Home Assistant event Platform (event.py, const.py, coordinator.py):
    • Adds event to PLATFORMS (configurable in Options across all 4 locales: en, fr, nb, pt).
    • Exposes Activity (event.<generator>_activity, entity_key = "activity") emitting outage_started, outage_ended, exercise_started, exercise_completed, fault_detected, and fault_cleared via a bounded sequenced ring buffer on GeneracDataUpdateCoordinator (preventing spurious re-fires on unrelated listener notifications like maintenance timer resets, while replaying transitions discovered on initial refresh after a restart).
  • Bundled Blueprint Bump actions/checkout from 3.5.3 to 4.1.1 #4 (generac_post_outage_summary.yaml):
    • Auto-installed alongside existing blueprints; waits for a Running outage (ignoring Exercising cycles and surviving mid-outage flaps) to stabilize in Ready, then sends an All Clear digest with outage duration, run hours added, estimated fuel used, optional propane autonomy, and hours until service.

Testing

  • pytest --maxfail=3 --disable-warnings --color=yes --no-cov — 188 passed (Python 3.14.10, pytest-homeassistant-custom-component==0.13.375), including new tests/test_event.py, v1 -> v2 migration & unobserved classification tests in tests/test_readiness.py, session sensor tests in tests/test_sensor.py, and end-to-end runtime execution tests for generac_post_outage_summary.yaml in tests/test_blueprints.py.
  • pre-commit run --all-files --show-diff-on-failure — all 8 hooks passed (flake8, reorder-python-imports, black, prettier, YAML/EOF/whitespace/large-file checks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant